#!/bin/ksh

echo "Please input the DATE of Backup!!"
echo "The Date format is: yyyymmdd"
echo "Press enter directly is to show Today's Backup logs"
read MYDATE

TEST=mytest$MYDATE

MYYEAR=`expr substr "$MYDATE" 3 2` 
MYMONTH=`expr substr "$MYDATE" 5 2` 
MYDAY=`expr substr "$MYDATE" 7 2` 

if [ $TEST = mytest ];then
  Serach_date=`date +%m`/`date +%d`/`date +%y`
else 
  Serach_date=${MYMONTH}/${MYDAY}/${MYYEAR}
fi

LOG=/usr/tivoli/tsm/client/log/dsmsche.log
grep "^$Serach_date" $LOG > /tmp/CKBackup1.log
grep -v "Normal File-" /tmp/CKBackup1.log | grep -v ANS1898I | grep -v "Expiring-->" | grep -v "Directory-->" >/tmp/tsmbackup.log 
TEST1=`grep -c "Successful incremental backup of" /tmp/tsmbackup.log`
if [ $TEST1 = 2 ]
then
  echo "                                      "
  echo " ******** Backup Sucessfully ******** "
  echo "                                      "
else
  echo "                                      "
  echo " ****** Backup May Have Error  ****** "
  echo " ****  Or Backup Is Running now ***** "
  echo "                                      "
fi
echo " The Detail Information as  following "
echo "                                      "
#tail -n17 /tmp/CKBackup1.log | grep -v "JCBACKUP NORMAL END cron script end" |awk '{print $0 $3 $4}'
LineBegin=`sed -n '/SCHEDULEREC OBJECT BEGIN SH_CRM_DB_SCHE/=' /tmp/tsmbackup.log`
LineEnd=`sed -n '/SCHEDULEREC OBJECT END SH_CRM_DB_SCHE/=' /tmp/tsmbackup.log`
Line =`wc -l /tmp/tsmbackup.log`
echo $LineBegin

sed -n "${LineBegin},${LineEnd}p"  /tmp/tsmbackup.log
#cat  /tmp/tsmbackup.log 
